﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Entity;

public partial class UserControl_ụcobStatus : System.Web.UI.UserControl
{
    TblStatusJobDAO JobStatusDAO = new TblStatusJobDAO(Global.CONNECTION_STRING);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            LoadJobStatus();
        }
    }
    private void LoadJobStatus()
    { 
        string id = Request.QueryString["id"];
        if (id != null)
        {
            grdJobStatus.DataSource = JobStatusDAO.GetJobStatus(Convert.ToInt32(id));
            grdJobStatus.DataBind();
        }
        else
        {
            txtNotes.Text = string.Empty;
            txtStatus.Text = string.Empty;
        }
    }
    protected void btnsave_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"];
        bool flag = false;
        try
        {
            TblJobStatus JobStatus = new TblJobStatus();
            JobStatus.JobID = Convert.ToInt32(id);
            JobStatus.StatusDate =Convert.ToDateTime(DateTime.Now);
            JobStatus.StatusJobs = txtStatus.Text;
            JobStatus.Notes = txtNotes.Text;
            JobStatusDAO.JobStatusIns(JobStatus);
            flag = true;
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE);
        }
        if (flag)
        {
            LoadJobStatus();
            txtNotes.Text = string.Empty;
            txtStatus.Text = string.Empty;
            //Response.Redirect("~/Booking.aspx?id=" + id);
            ScriptManager.RegisterStartupScript(btnsave, btnsave.GetType(), "ScriptLoginSuccess", "UpdateParentsLogin();", true);
        }
    }
  
}
